package com.sky.mapper;

import com.sky.entity.AddressBook;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface AddressBookMapper {
    /**
     * 查询当前登录用户的所有地址信息
     * @return
     */
    @Select("select * from address_book where user_id = #{id}")
    List<AddressBook> list(Long id);

    /**
     * 新增地址
     * @param addressBook
     */
    void add(AddressBook addressBook);

    /**
     * 获取默认地址
     * @param id
     */
    @Select("select * from address_book where is_default = #{isDefault}")
    AddressBook getDefault(int id);

    /**
     * 根据id查询地址
     * @param id
     * @return
     */
    @Select("select * from address_book where id = #{id}")
    AddressBook getById(Long id);

    /**
     * 根据id修改地址
     * @param addressBook
     */
    void update(AddressBook addressBook);

    @Delete("delete from address_book where id = #{id}")
    void del(Long id);
}
